/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.ucase.casemain.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CaseMainDetailInfoQueryDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CaseMainDetailInfoSaveDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.model.CaseMainDetailInfo;
import com.icinfo.cloud.provider.punish.ucase.casemain.service.ICaseMainDetailInfoService;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseCurrentLinkOperateVo;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseMainDetailInfoVo;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseRecallLinkVo;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseStageDocumentRelationInfoVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述: 案件主要详情表（宽表）-TRJ case_main_detail_info 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年02月16日
 */
@RestController
@RefreshScope
@RequestMapping("/punish/ucase/case/main/detail")
@Slf4j
public class CaseMainDetailInfoController extends BaseController {

    @Resource
    private ICaseMainDetailInfoService caseMainDetailInfoService;

    /**
     * 【V1.0.0】描述：保存案件主要详情信息
     *
     * @param saveDto {@link CaseMainDetailInfoSaveDto}
     * @return {@link Result<String>} 保存结果
     * @author xiangyuyu
     * @date 2022-02-16 16:02
     */
    @PostMapping("/saveCaseMainDetailInfo")
    @ApiOperation(value = "【V1.0.0】描述：保存案件主要详情信息", httpMethod = "POST")
    public Result<String> saveCaseMainDetailInfo(@RequestBody @Validated CaseMainDetailInfoSaveDto saveDto) {
        return caseMainDetailInfoService.saveCaseMainDetailInfo(saveDto);
    }

    /**
     * 【V1.0.0】描述：获取案件主要详情列表
     *
     * @param queryDto {@link CaseMainDetailInfoQueryDto}
     * @return {@link Result<List<CaseMainDetailInfoVo>} 案件主要详情列表
     * @author xiangyuyu
     * @date 2022-02-16 16:02
     */
    @PostMapping("/getCaseMainDetailList")
    @ApiOperation(value = "【V1.0.0】描述：获取案件主要详情列表", httpMethod = "POST")
    public Result<List<CaseMainDetailInfoVo>> getCaseMainDetailList(@RequestBody @Validated CaseMainDetailInfoQueryDto queryDto) {
        List<CaseMainDetailInfoVo> list = caseMainDetailInfoService.getCaseMainDetailList(queryDto);
        return Result.success(Constant.STRING_GET_SUCCESS, list);
    }

    /**
     * 【V1.0.0】描述：根据唯一标识查询案件主要详情信息
     *
     * @param id 唯一标识
     * @return {@link Result<CaseMainDetailInfoVo>} 案件主要详情信息
     * @author xiangyuyu
     * @date 2022-02-16 16:02
     */
    @PostMapping("/getCaseMainDetailInfo")
    @ApiOperation(value = "【V1.0.0】描述：根据唯一标识查询案件主要详情信息", httpMethod = "POST")
    public Result<CaseMainDetailInfoVo> getCaseMainDetailInfo(@RequestParam String id) {
        CaseMainDetailInfoVo vo = caseMainDetailInfoService.getCaseMainDetailInfo(id);
        return Result.success(Constant.STRING_GET_SUCCESS, vo);
    }

    /**
     * 【V1.0.0】描述：删除案件主要详情信息
     *
     * @param id 主键id
     * @return {@link Result<String>} 删除结果
     * @author xiangyuyu
     * @date 2022-02-16 16:02
     */
    @PostMapping("/removeCaseMainDetail")
    @ApiOperation(value = "【V1.0.0】描述：删除案件主要详情信息", httpMethod = "POST")
    public Result<String> removeCaseMainDetail(@RequestParam String id) {
        return caseMainDetailInfoService.removeCaseMainDetail(id);
    }
    /**
     * 【V1.0.0】描述：根据案件id获取案件详情数据
     * @author liyafeng
     * @date 2022/2/25
      * @param caseId
     * @return {@link Result< String>}
     */
    public Result<CaseMainDetailInfo> getCaseMainDetailByCaseId(@RequestParam String caseId) {
        CaseMainDetailInfo caseMainDetailInfo=caseMainDetailInfoService.getCaseMainDetailByCaseId(caseId);
        return Result.success(caseMainDetailInfo);
    }

    /**
     * 【V1.3.0】描述：根据案件id获取可撤回的列表
     * @author tianrunjia
     * @date 2022/6/24
     * @param caseId
     * @return {@link Result< CaseRecallLinkVo>}
     */
    @GetMapping("/getCaseRecallLink")
    @ApiOperation(value = "【V1.3.0】描述：根据案件id获取可撤回的列表", httpMethod = "GET")
    public Result<List<CaseRecallLinkVo>> getCaseRecallLinkById(@RequestParam String caseId) {
        List<CaseRecallLinkVo> caseRecallLinkVoList=caseMainDetailInfoService.getCaseRecallLinkListById(caseId);
        return Result.success(caseRecallLinkVoList);
    }

    /**
     * 【V1.4.1】描述：返回案件主流程当前环节的操作按钮-详情页底部，包括流程操作、下一步、更多操作
     * @author tianrunjia
     * @date 2022/8/24
     * @param caseId
     * @return {@link Result< CaseRecallLinkVo>}
     */
    @GetMapping("/getCaseCurrentLinkOperate")
    @ApiOperation(value = "【V1.4.1】描述：返回案件当前环节的操作按钮-详情页底部，包括流程操作、下一步、更多操作", httpMethod = "GET")
    public Result<CaseCurrentLinkOperateVo> getCaseCurrentLinkOperate(@RequestParam(value="caseId") String caseId){
        CaseCurrentLinkOperateVo caseCurrentLinkOperateVo = caseMainDetailInfoService.doGetCaseCurrentLinkOperate(caseId);
        return Result.success(caseCurrentLinkOperateVo);
    }

    /**
     * 【V1.10.0】描述：获取文书按阶段的列表及每个文书的状态及对应的操作
     * @author tianrunjia
     * @date 2022/12/11
     * @param caseId
     */
    @GetMapping("/getCaseStageDocumentDetailInfos")
    @ApiOperation(value = "【V1.10.0】描述：获取文书按阶段的列表及每个文书的状态及对应的操作", httpMethod = "Get")
    public Result<List<CaseStageDocumentRelationInfoVo>> getCaseStageDocumentDetailInfos(@RequestParam String caseId) {
        List<CaseStageDocumentRelationInfoVo> caseStageDocumentDetailInfoVos = caseMainDetailInfoService.getCaseStageDocumentDetailInfos(caseId);
        return Result.success(Constant.STRING_GET_SUCCESS, caseStageDocumentDetailInfoVos);
    }

}